/**
 *  Copyright (C) 2007 Marcos Diez < marcos AT unitron.com.br >
 *  Copyright (C) 2005 PGT-Linux.org http://www.pgt-linux.org
 *  Author: vandorpe Olivier <vandorpeo@pgt-linux.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef _USBB2KAPI_H_
#define _USBB2KAPI_H_

#include <usb.h>

#define USBB2K_API_VERSION 2.08



#define OFF	  0
#define ON	  1


#define ERR	-1

#define USB_MODE	1
#define PSTN_MODE	2

#define SERIAL_NUMBER_SIZE 11

#define KEY_0   0x00
#define KEY_1   0x01
#define KEY_2   0x02
#define KEY_3   0x03
#define KEY_4   0x04
#define KEY_5   0x05
#define KEY_6   0x06
#define KEY_7   0x07
#define KEY_8   0x08
#define KEY_9   0x09
#define KEY_STAR 0x0b
#define KEY_POUN 0x0c

enum { 	YEALINK_DEVICE_NOT_FOUND , 
		YEALINK_DEVICE_NOT_OPENED ,
		YEALINK_DEVICE_NOT_CLAIMED, // are you root ?
		YEALINK_DEVICE_NOT_B2KB3G ,
		YEALINK_DEVICE_NOT_INITIALIZED , 
		YEALINK_DEVICE_SUCESSIFULLY_INITIALIZED ,
		YEALINK_DEVICE_UNKNOWN 
		
};

typedef struct strYealinkDevice_t{
  int socketFD;               // to write output (unbuffered/nonblocking)
  FILE *socketFile;		  // to read input (buffered/blocking)
  char *socketName;
  usb_dev_handle *dev_h;  // for libUSB
  int usbBusNumber;
  int usbDeviceNumber;
  int deviceVersion;      
  unsigned char serialNumber[ SERIAL_NUMBER_SIZE +1];

  struct myOptions {
  	unsigned halMode :1;
  	unsigned foregroundMode :1;
  } options;

} yealinkDevice_t;


#define TEL_ERR ((char) 0xfd) /* vendor code for busy, stalled, or error? */


// the last byte is the checksum: ( negatime sum of the first 15 bytes )



#endif
